package cn.ekuma.epos.datalogic.define.dao.sale;

import e.odbo.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.pos.I_PosSharedProduct;
import com.openbravo.bean.Product;
import com.openbravo.bean.sales.PosSharedProduct;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.serialize.DataRead;
import com.openbravo.data.loader.serialize.DataWrite;
import com.openbravo.data.loader.serialize.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.table.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class PosSharedProductDAO extends BaseDAO<PosSharedProduct>{

	public PosSharedProductDAO(I_Session s) {
		super(s);
	}

	@Override
    public TableDefinition getTable() {
        return new TableDefinition(
                "POSSHAREDPRODUCTS",
                new Field[]{
                        new Field(I_PosSharedProduct.PRODUCT, Datas.STRING, Formats.STRING,Product.class),
                        new Field(I_PosSharedProduct.KEYSTOKE, Datas.STRING, Formats.STRING)
                },
                new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, PosSharedProduct obj) throws BasicException {
          dp.setString(1, obj.getProductId());
          dp.setString(2,obj.getKeyStoke());    
    }

    public PosSharedProduct readValues(DataRead dr,PosSharedProduct obj) throws BasicException {
        if(obj==null)
        	obj=new PosSharedProduct();
        obj.setProductId(dr.getString(1));
        obj.setKeyStoke(dr.getString(2));
    	return obj;
    }

	@Override
	public Class getSuportClass() {
		return PosSharedProduct.class;
	}
}
